package com.springboot.demo.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.springboot.demo.entity.Book;
import com.springboot.demo.mapper.SearchBookMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.UnsupportedEncodingException;
import java.util.List;

@Service
public class SearchBookService extends ServiceImpl<SearchBookMapper, Book> {
    @Autowired
    private SearchBookMapper searchBookMapper;

    public List<Book> getBook(String bookname) throws UnsupportedEncodingException {
        String name=new String(bookname.getBytes("8859_1"), "utf8");
        return (List<Book>) searchBookMapper.getBook(name);
    }

    public List<Book> getBook1(String bookname,String bookauthor) throws UnsupportedEncodingException {
        String name=new String(bookname.getBytes("8859_1"), "utf8");
        String author=new String(bookauthor.getBytes("8859_1"), "utf8");
        return searchBookMapper.getBook1(name,author);
    }

    public List<Book> getAllBook(){
        return searchBookMapper.getAllBook();
    }

    public Book getBookByID(long id){
        return searchBookMapper.getBookByID(id);
    }

}